using System.IO;
using System.Text;
using System.Windows.Forms;

namespace CodeTools {
    internal class MyConsoleTextWriter : TextWriter {
        private readonly RichTextBox _outputControl;

        public MyConsoleTextWriter(RichTextBox outputControl) {
            _outputControl = outputControl;
        }

        public override Encoding Encoding {
            get { return Encoding.ASCII; }
        }

        public override void Write(char value) {
            if (value == '\r') {
                return;
            }
            _outputControl.SelectedText = "" + value;
        }
    }
}